﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FortuneHeavenCommon.DataMap;
using System.Data.SqlClient;

namespace FortuneHeavan.Game.DAL
{
    public class RecordUserLeaveDAL:TreasureDBBase
    {
        public List<RecordUserLeave> GetUserLeaveRecord(int userid)
        {
            string sql = "Select * from RecordUserLeave where UserID =@UserID";
            List<RecordUserLeave> content = Query<RecordUserLeave>(sql, new SqlParameter("@UserID", userid));
            return content;
        }
        public List<RecordUserLeave> GetUserLeaveRecordList(int page, int size,  int userid)
        {
            string sql = @"select * from (
select A.*,B.KindName
,ROW_NUMBER() OVER(ORDER BY A.LeaveTime DESC) ROW 
from RecordUserLeave A inner join QPServerInfoDB.dbo.GameKindItem B on A.KindID= B.KindID  where  A.UserID =@UserID) FF
 WHERE FF.ROW BETWEEN  @p1 AND @p2"; ;
            List<RecordUserLeave> list = Query<RecordUserLeave>(sql, new SqlParameter("@UserID", userid), new SqlParameter("@p1", size * (page - 1) + 1), new SqlParameter("@p2", size * page));
            return list;
        }
        public int GetTotalSize(int userid)
        {
            string sql = @"select count(A.UserID) from RecordUserLeave A inner join QPServerInfoDB.dbo.GameKindItem B on A.KindID= B.KindID  where  A.UserID =@UserID";
            return RunSQL(sql, new SqlParameter("@UserID", userid));
        }
    }
}
